﻿using System;
using System.Collections.Generic;
using System.Web;
using FOBTV.Web.DBUtility;
using System.Data.OleDb;

namespace FOBTV.Web.MainClass
{
    public class SessionState
    {
        static readonly string userId = "currentUser";

        static T GetSessionState<T>(string index)
        {
            return (T)HttpContext.Current.Session[index];
        }

        static T GetSessionState<T>(string index, object defaultValue)
        {
            return HttpContext.Current.Session[index] == null ? (T)defaultValue : (T)HttpContext.Current.Session[index];
        }

        static void SetSessionState(string index, object value)
        {
            HttpContext.Current.Session[index] = value;
        }

        public static void ClearSession()
        {
           HttpContext.Current.Session.Clear();
           // HttpContext.Current.Session.Abandon();
        }

        public static User CurrentUser
        {
            get { return GetSessionState<User>(userId, new User()); }
            set { SetSessionState(userId, value); }
        }
    }

    public class User
    {
        public string CustomerID { get; set; }
        public string Email { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Prefix { get; set; }
        public string BusinessTitle { get; set; }
        public string FullCompanyName { get; set; }
        public string Address { get; set; }
        public string Address2 { get; set; }
        public string Address3 { get; set; }
        public string PostalCode { get; set; }
        public string Passport { get; set; }
        public DateTime Birthday { get; set; }
        public int State { get; set; }
        public DateTime CreatPDFTime { get; set; }

    }

	public class FOBTVAdmin
	{
		public string Username { get; set; }
		public string DisplayName { get; set; }
	}

	[Table("News", "ID")]
	public class FOBTVNews:BaseInfo
	{
		[Property("ID", OleDbType.BigInt, false, false)]
		public Int64 ID { get; set; }

		[Property("NewsTitle", OleDbType.VarChar, false, false)]
		public string NewsTitle { get; set; }

		[Property("NewsContent", OleDbType.VarChar, false, false)]
		public string NewsContent { get; set; }

		[Property("NewsType", OleDbType.VarChar, false, false)]
		public string NewsType { get; set; }

		[Property("NewsSource", OleDbType.VarChar, false, false)]
		public string NewsSource { get; set; }

		[Property("NewsCategory", OleDbType.VarChar, false, false)]
		public string NewsCategory { get; set; }

		[Property("Publisher", OleDbType.VarChar, false, false)]
		public string Publisher { get; set; }

		[Property("IsRecommend", OleDbType.VarChar, false, false)]
		public bool IsRecommend { get; set; }

		[Property("NewsIndex", OleDbType.Integer, false, false)]
		public int NewsIndex { get; set; }

		[Property("PublishDate", OleDbType.Date, false, false)]
		public DateTime PublishDate { get; set; }
	}
}